package com.zk.yygh.oss.controller;

import com.zk.yygh.hosp.result.Result;
import com.zk.yygh.oss.service.OSSService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author: 张凯
 * @date: 2022/6/17 - 9:52
 */
@Api(value = "阿里云OSS文件对象存储接口")
@RestController
@RequestMapping("/api/oss")
@CrossOrigin    //虽然配置了网关，但是前段依旧要写上端口号和后端要写上该注解，不然上传的就不是文件，空指针异常
public class OSSController {

    @Autowired
    private OSSService ossService;

    @ApiOperation(value = "文件上传")
    @PostMapping("/fileUpLoad")
    public Result fileUpLoad(MultipartFile file){
        String url = ossService.fileUpLoad(file);
        return Result.ok(url);
    }
}
